package org.apache.ocean.main.merge;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.ocean.main.client.OceanXML;
import org.apache.ocean.main.http.HttpParameters;
import org.apache.ocean.main.http.HttpTimeout;
import org.apache.ocean.main.name.Node;
import org.jdom.Element;

public class MergeNameClient {
	
	public static void registerForNodeEvents(URL url, String cell, long duration, HttpTimeout httpTimeout) throws Exception {
		HttpParameters parameters = new HttpParameters();
  	parameters.add("action", "registerfornodeevents");
  	parameters.add("cell", cell);
  	parameters.add("duration", duration);
  	OceanXML response = OceanXML.request(url, parameters, httpTimeout);
	}
	
  public static List<Node> getCellNodes(URL url, String cell, HttpTimeout httpTimeout) throws Exception {
  	HttpParameters parameters = new HttpParameters();
  	parameters.add("action", "getcellnodes");
  	OceanXML response = OceanXML.request(url, parameters, httpTimeout);
  	List<Node> nodes = new ArrayList<Node>();
  	for (Element element : response.getBodyChildren()) {
  		nodes.add(new Node(element));
  	}
  	return nodes;
  }
}
